// 更多配置: https://www.npmjs.com/package/@cxxgo/genapi
import { type UserConfig } from '@cxxgo/genapi'

const config: UserConfig = {
  apiList: [
    {
      // swaggerUrl: 'http://192.168.40.84:8093/v2/api-docs',
      swaggerUrl: 'http://192.168.16.103:8093/v2/api-docs',
      outputDir: '/src/genapi'
    }
  ],
  httpTpl: "import request from '@/api/request/index'",
  apiBody: ({
    url,
    method,
    summary,
    name,
    parameters,
    outputInterface,
    pstr1,
    pstr2
  }) => {
    return `
      /** ${summary || '无注释'} */
      export function ${name}  (${pstr1}) :Promise<${outputInterface || undefined
      }>{
        return request.${method}('${url}', ${pstr2})
      }`
  },
  // apiBody: ({
  //   url,
  //   method,
  //   summary,
  //   name,
  //   outputInterface,
  //   pstr1,
  //   pstr2,
  //   pstr3
  // }) => {
  //   const quotation = pstr3 ? '`' : "'" // 引号类型
  //   return `
  //       /** ${summary || '无注释'} */
  //       export function ${name}  (${pstr1}) :Promise<${
  //     outputInterface || undefined
  //   }>{
  //         ${pstr3 || ''}
  //         return Http.${method}(${quotation}${url}${quotation}, ${pstr2})
  //       }`
  // },
  mock: {
    fieldRules: {
      code: 200,
      current: 1,
      size: 20,
      total: '@integer(1, 50)'
    }
  }
}

export default config
